<?php

include 'config.php';
	$con = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME) or die ("Could not execute query");
///////////////////////////////////////////////////////////////////////////queries	
	///////context
	$query_context = "SELECT DISTINCT context FROM d3 WHERE userid = 1";
	$result_context = mysqli_query($con, $query_context) or die ("Could not SELECT context FROM d3");
	$nrows_context =  mysqli_num_rows($result_context);
	$row_context = mysqli_fetch_assoc($result_context);
  	//print_r($row_context);
  	
  		while ($row_context = mysqli_fetch_array($result_context))
{
		echo $row_context[0];
	}
 
?>

		{
	"name": "userid",
	"children": [
		{
			"name": "personal context",
			"children": [
				{				
					"name": "skill 1",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 2",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 3",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 4",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 5",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 6",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 7",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}
			]
		}, {
			"name": "work context",
			"children": [
				{
					"name": "skill 1",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 2",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 3",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 4",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 5",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 6",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 7",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}
			]
		}, 
		{
			"name": "academic context",
			"children": [
				{
					"name": "skill 1",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 2",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 3",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 4",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 5",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 6",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}, {
					"name": "skill 7",
					"children": [
						{
							"name": "lex 1"
						}, {
							"name": "lex 2"
						}, {
							"name": "lex 3"
						}
					]
				}
			]
		}
			]
		}